from selenium import webdriver
from selenium.webdriver.common.by import By
import time


d = webdriver.Chrome()
d.get("https://www.baidu.com")
time.sleep(1)

# 获取标题
print(d.title)

# 获取当前窗口的网址
print(d.current_url)

# 获取属性对应的值d.find_element('属性名称')获取该属性对应的值
button_ele = d.find_element(By.CSS_SELECTOR, '[name="wd"]')
res = button_ele.get_attribute('id')  # 获取 id 这个属性对应的值
print(res)

# 获取文本信息  .text 获取该元素的文本信息
link_ele = d.find_element(By.CSS_SELECTOR, '[class="title-content-title"]')
res2 = link_ele.text
print(res2)
